package com.mini.service.impl;

import com.mini.dao.DatasourceTypeMapper;
import com.mini.pojo.basic.DatasourceType;
import com.mini.service.DatasourceTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class DatasourceTypeServiceImpl implements DatasourceTypeService {

    @Autowired
    private DatasourceTypeMapper datasourceTypeMapper;

    public void addDatasourceType(DatasourceType datasourceType) {
        datasourceType.setCreatedBy("test");
        datasourceType.setCreatedTime(new Date());
        datasourceType.setUpdatedBy("test");
        datasourceType.setUpdatedTime(new Date());
        datasourceTypeMapper.addDatasourceType(datasourceType);
    }

    public void updateDatasourceType(DatasourceType datasourceType) {
        datasourceType.setUpdatedBy("test");
        datasourceType.setUpdatedTime(new Date());
        datasourceTypeMapper.updateDatasourceType(datasourceType);
    }

    public void removeDatasourceType(int datasourcetypeID) {
        DatasourceType datasourceType = datasourceTypeMapper.queryDatasourceType(datasourcetypeID);
        datasourceType.setUpdatedBy("test");
        datasourceType.setUpdatedTime(new Date());
        datasourceTypeMapper.removeDatasourceType(datasourceType);
    }

    public DatasourceType queryDatasourceType(int datasourcetypeID) {

        return datasourceTypeMapper.queryDatasourceType(datasourcetypeID);
    }

    public List<DatasourceType> queryAllDatasourceType() {
        return datasourceTypeMapper.queryAllDatasourceType();
    }
}
